package pl.edu.pw.perg.compinfodb.datamodel;

import javax.swing.tree.DefaultMutableTreeNode;

@SuppressWarnings("serial")
public class SelectableTreeNode extends DefaultMutableTreeNode {

  private boolean selected;
  private boolean visible;

  public boolean isSelected() {
    return selected;
  }

  public void setSelected(boolean selected) {
    this.selected = selected;
    if (children != null)
      for (Object node : children) {
        ((SelectableTreeNode) node).setSelected(selected);
      }
  }

  public SelectableTreeNode(Object obj) {
    super(obj);
    selected = false;
    visible = true;
  }

  public SelectableTreeNode(SelectableTreeNode node) {
    this(node.userObject);
    setSelected(node.selected);
  }

  public boolean isVisible() {
    return visible;
  }

  public void setVisible(boolean visible) {
    this.visible = visible;
    if (children != null)
      for (Object node : children) {
        ((SelectableTreeNode) node).setVisible(visible);
      }
  }
  
  

}
